def func(s):
    digit_num=0
    al_num=0
    space_num=0
    other_num=0
    for i in s:
        if i.isdigit():
            digit_num+=1
        elif i.isspace():
            space_num+=1
        elif i.isalpha():
            al_num+=1
        else:
            other_num+=1
    return (digit_num,al_num,space_num,other_num)
result=func("asdnjw    1244  @@上下")
print(result)
result=func("aaa123  @@")
print(result)
#判断字符串，列表，元组长度是否大于五
def function(s,list,tub):
    zifuchuan=len(s)
    liebiao=len(list)
    yuanzu=len(tub)
    if zifuchuan>5:
        print("大于5")
    else:
        print("小于5")
    if liebiao>5:
        print("大于5")
    else:
        print("小于5")
    if yuanzu>5:
        print("大于5")
    else:
        print("小于5")
function("12344555",[1,2,3],(1,1,4,4,4,4))
#3
def func(n):
    for i in a:
        i = str(i)
        if '' in i:
            return ('有空格： ',i)
        else:
            return ('没空格')
a = ('dasdsd dasd','ds')
res = func(a)
print(res)
#4
def func(li):
    len_li=len(li)
    if len_li>2:
        print("列表长度大于2")
        new_li=li[0:2]
    return new_li
res=func([1,2,3,4,4])
print(res)
#写函数，检查获取传⼊列表或元组的所有奇数位索引对应的元素，并将其作为新列表返回给调⽤者
def func(li,tup):
    li1 = []
    tup1 = []
    for i in range(len(li)):
        if i %2 ==1:
            li1.append(li[i])
    for j in range(len(tup)):
        if j %2 ==1:
            tup1.append(tup[j])
    return (li1,tup1)
res = func([1,2,3,4,5,6,7,8,9],(1,2,3,11,21,4,5,6,7))
print(res)
#农业银行账户管理系统
class Address:
    def __init__(self,country,province,street,door_number):
        self.country=country
        self.province=province
        self.street=street
        self.door_number=door_number
    #自定义字符串类型
    def __str__(self):
        return f"{self.country}{self.province}{self.street}{self.door_number}"
import random
class User:
    def __init__(self,account_type,name,password,address,balance,bank_name):
        self.account_number=random.randint(10000000, 99999999)
        self.account_type=account_type
        self.name=name
        self.password=password
        self.address=address
        self.balance=balance
        self.bank_name=bank_name
    def __str__(self):
       account_type_per= '金卡' if self.account_type == 1 else '普通'
       return (f"当前账号：{self.account_number}密码：{self.password}类型：{account_type_per}用户居住地址：{self.address}"
               f"当前账户开户行：{self.bank_name}")

    def accout_limit(self):  # 转账限额
        return 50000 if self.account_type == 1 else 20000
class Bank:
    def __init__(self,name):
        self.name=name
        self.users={}#账户信息
#开户
    def open_account(self, user):
       if len(self.users)>=100:
            return 3
       if user.account_number in self.users:
            return 2
       self.users[user.account_number]=user
       return 1
    #存钱
    def deposit(self,account_number,ammount):
        if account_number not in self.users:
            return False
        self.users[account_number].balance += float(ammount)
        return True
    #取钱
    def withdraw(self,account_number,password,ammount):
        if account_number not in self.users:
            return 1
        user = self.users[account_number]
        if user.password != password:
            return 2
        if user.balance < ammount:
            return 3
        user.balance -= ammount
        return 0
    #转账
    def transfer(self,out_count,in_count,out_password,out_ammount):
        if (out_count not in self.users )or (in_count not in self.users):
            return 1#账号不存在
        if self.users[out_count].password!=out_password:
            return 2#密码错误
        if self.users[out_count].balance<out_ammount:
            return 3#金额不足
        if self.users[out_count].accout_limit()<out_ammount:
            return 4#转账超出限额
        self.users[out_count].balance -= out_ammount
        self.users[in_count].balance += out_ammount
        return 0
 #查询账户
    def query(self,account_number,password):
        if account_number not in self.users:
            print("该用户不存在")
            return
        if password != self.users[account_number].password:
            print("密码不正确")
            return
        user=self.users[account_number]
        print(f"当前账号：{account_number} 密码：{password} 余额：{user.balance:.2f}"
              f"现住地址：{user.address} 开户行：{user.bank_name}")
class ATM:
    def __init__(self,bank):
        self.bank=bank#将bank实例化对象赋给self.bank对象
    def show_menu(self):
        print("\n中国农业银行账户管理系统")
        print("1.开户 2.存钱 3.取钱 4.转账 5.查询 6.退出")
    def handle_choice(self,choice):
        if(choice == "1"):
            self.open_account()
        elif choice == '2':
            self.deposit()
        elif choice == '3':
            self.withdraw()
        elif choice == '4':
            self.transfer()
        elif choice == '5':
            self.query()
        elif choice == '6':
            print("感谢使用，再见！")
            return False
        return True
    #account_type,name,password,address,balance,bank_name
    def open_account(self):
        account_type=int(input('账户类型：1.金卡 2.普通卡'))
        name=input('姓名：')
        password=input("密码：")
        address=input('地址：')
        balance=float(input('初始金额：'))
        bank_name=input("开户行：")
        user=User(account_type,name,password,address,balance,bank_name)
        result=self.bank.open_account(user)
        if result == 1:
            print(f"开户成功！账号：{user.account_number}")
        elif result == 2:
            print("失败：用户已存在")
        else:
            print("用户库已满，添加失败")
    #存钱account_number,ammount
    def deposit(self):
        account_number = int(input("账号："))
        ammount = float(input("存款金额："))
        if self.bank.deposit(account_number,ammount):
            print(f"存款成功！当前账户余额:{self.bank.users[account_number].balance}")
        else:
            print("失败，账号不存在")
    #取钱account_number,password,ammount
    def withdraw(self):
        account_number = int(input("账号："))
        password=input("密码：")
        ammount = float(input("取款金额："))
        result=self.bank.withdraw(account_number,password,ammount)
        if result == 1:
            print("账户不存在")
        elif result == 2:
            print("密码错误")
        elif result == 3:
            print("余额不足")
        else:
            print(f"取款成功!当前余额为{self.bank.users[account_number].balance}")
    #转账out_count,in_count,out_password,out_ammount
    def transfer(self):
        out_count=int(input("转出账号："))
        in_count=int(input("转入账号："))
        out_password=input("转出账号密码：")
        out_ammount=float(input("转出金额："))
        result=self.bank.transfer(out_count,in_count,out_password,out_ammount)
        if result==0:
            print(f"转账成功！转账金额为{out_ammount}")
            print(f"转出账号余额：{self.bank.users[out_count].balance:.2f}")
            print(f"转入账号余额：{self.bank.users[in_count].balance:.2f}")
        elif result == 1:
            print("失败，账号不存在")
        elif result == 2:
            print("失败，密码错误")
        elif result == 3:
            print("失败，余额不足")
        elif result == 4:
            print("失败，转账超出限额")
            print(f'您的账户类型为{self.bank.users[out_count].account_type},单次限额为{self.bank.users[out_count].accout_limit()}元')
        else:
            print("\n未知错误")
        #查询account_number,password
    def query(self):
        account_number=int(input("账号："))
        password=input("密码：")
        self.bank.query(account_number,password)
#主程序
bank=Bank("中国农业银行昌平沙河支行")
atm=ATM(bank)
while True:
    atm.show_menu()
    choice=input("请选择业务：")
    if not atm.handle_choice(choice):
        break














